<template>
	<view>
		<view class="table-view-group" v-if="datas.length">
			<view class="table-cell-block" v-for="item in datas" :key="item.id">
				<view class="table-cell-block__hd">
					<text class="iconfont" v-if="item.type == 0">&#xe690;</text>
					<text class="iconfont" v-if="item.type == 1" style=" color: #ef9741;">&#xe691;</text>
					<text class="iconfont" v-if="item.type == 2" style=" color: #ec5f51;">&#xe692;</text>
					<text class="iconfont" v-if="item.type == 3">&#xe693;</text>
				</view>
				<view class="table-cell-block__bd">
					<view class="name">{{item.description}}</view>
					<view class="way">
						<text v-if="item.type == 0">[收入]</text>
						<text v-if="item.type == 1">[支出]</text>
						<text v-if="item.type == 2">[冻结]</text>
						<text v-if="item.type == 3">[解冻]</text>
					</view>
					<view class="date">{{item.addtime}}</view>
				</view>
				<view class="table-cell-block__fd">
					<text class="num" style=" color: #2dbb55;" v-if="item.type == 0">+{{item.amount}}</text>
					<text class="num" v-else>-{{item.amount}}</text>
				</view>
			</view>
		</view>
		
		<uni-load-more :status="more" v-if="datas.length"></uni-load-more>
		
		<st-empty-msg noMsg="暂无交易明细" :showHande="false" v-if="!datas.length"></st-empty-msg>
		
	</view>
</template>

<script>
	var page = 1,
		pagesize = 10;	
	export default {
		components:{
		
		},
		data() {
			return {
				datas: [],
				more: 'noMore'
			}
		},
		onLoad() {
			page = 1;
			this.getListDatas()
		},
		onReachBottom() {
			this.getListDatas()
		},
		methods: {
			
			// 明细列表
			async getListDatas(){
				let params, bnsRes;
				params = {
					method: "api/v2/member/bag/cash_log",
					type: "",
					page,
					page_size: pagesize
				}
				bnsRes = await this.$http(params);
				this.more = 'loading';
				if(bnsRes.status){
					this.datas = [...this.datas, ...bnsRes.data.list];
					if(bnsRes.data.list.length < pagesize){
						this.more = 'noMore';
					}
					page++
				}else{
					uni.showToast({
						title: bnsRes.msg,
						icon: "none"
					})
				}
			}
			
		}
	}
</script>

<style lang="scss">

	.table-view-group{
		margin-bottom: 20rpx;
		background-color: $uni-bg-color;
	}
	.table-cell-bar{
		
	}
	.table-cell-block{
		display: flex;
		align-items: center;
		justify-content: space-between;
		padding: 24rpx 24rpx 24rpx 30rpx;
		position: relative;
		&:after{
			content: "";
			position: absolute;
			right: 0;
			left: 100rpx;
			bottom: 0;
			height: 1px;
			-webkit-transform: scaleY(0.5);
			transform: scaleY(0.5);
			background-color: $uni-border-color;
		}
		&:last-child:after{
			display: none;
		}
		&__hd{
			flex: 0 0 auto;
			width: 120rpx;
			font-size: $uni-font-size-base;
			.iconfont{
				color: #2dbb55;
				font-size: 80rpx;
			}
		}
		&__bd{
			flex: 1 1 auto;
			.name{
				font-size: 26rpx;
			}
			.way{
				margin-top: 8rpx;
				font-size: $uni-font-size-mini;
			}
			.date{
				color: $uni-text-color-grey;
				margin-top: 8rpx;
				font-size: $uni-font-size-mini;
			}
		}
		&__fd{
			flex: 0 0 auto;
			.num{
				font-size: $uni-font-size-lg;
				font-weight: bold;
				font-family: Arial, Helvetica, sans-serif;
			}
		}
	}

</style>
